package com.gds.wiki.cloud.admin.server.modular.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gds.wiki.cloud.admin.client.sys.model.Resource;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/*
* 
* gen by beetlsql mapper 2018-04-23
*/
public interface ResourceMapper extends BaseMapper<Resource> {

    @Select("select DISTINCT(c.id),c.pid,c.name from sys_role a join sys_role_resource b on a.id=b.role_id " +
            "join sys_resource c on b.resource_id=c.id where a.id=#{rid} order by a.seq desc")
    List<Resource> getResourceByRoleId(Long rid);

    @Select("select DISTINCT a.* from sys_resource a join sys_role_resource b on a.id=b.resource_id join sys_user_role c on b.role_id=c.role_id " +
            "join sys_role d on d.id=b.role_id " +
            "where c.user_id=#{uid} and a.status!=-1 and a.resource_type=0 order by a.pid,a.seq")
    List<Resource> getMenuVoList(Long uid);

    List<Map> findDeptResource(Map map);

    @Select("select a.url,d.name from sys_resource a join sys_role_resource b on a.id=b.resource_id join sys_user_role c on b.role_id=c.role_id " +
            "join sys_role d on d.id=b.role_id " +
            "where c.user_id=#{uid}")
    List<Map> findUserResourceByUid(Long uid);
}
